#!/bin/bash
#
# 4shared.com module
# Copyright (c) 2010-2012 Plowshare team
#
# This file is part of Plowshare.
#
# Plowshare is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Plowshare is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Plowshare.  If not, see <http://www.gnu.org/licenses/>.

MODULE_MIT_REGEXP_URL="https://.*.mit.edu/.*"

MODULE_MIT_DOWNLOAD_OPTIONS=""
MODULE_MIT_DOWNLOAD_NO_SSL_CERTS=yes
MODULE_MIT_DOWNLOAD_RESUME=yes
MODULE_MIT_DOWNLOAD_FINAL_LINK_NEEDS_COOKIE=no

MODULE_MIT_LIST_OPTIONS=""

mit_download() {
local COOKIEFILE=$1
local URL=$2

FILE_URL=$(echo $URL)
echo $FILE_URL

}

mit_list() {

local URL=$1

	Pageinit=$(curl -k "$URL") || return 
  IFS=$'\n'
  links=( $(echo $Pageinit | break_html_lines | grep 'class=icon' ) )
  
 # echo ${links[@]} > links
 
for (( j=1 ; j < ${#links[@]} ; j++ )) do     
 final=$( echo ${links[$j]} | parse_attr 'a' 'href')
 final=$( echo "$URL$final" )
 echo "$final"
done
	
}